
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3、Runtime · zhoufei-iosknowledges</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhoufei">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="3.1.html" />
    
    
    <link rel="prev" href="../oc/2.9.html" />
    

    
        <link rel="shortcut icon" href='../../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='../../source/images/apple-touch-icon.jpg'>
    
    
        
        <link rel="apple-touch-icon" sizes="120x120" href="../../source/images/apple-touch-icon.jpg">
        
        <link rel="apple-touch-icon" sizes="180x180" href="../../source/images/apple-touch-icon.jpg">
        
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"zhou415770319","repo":"iosKnowledges","type":"star","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.feiyum.cn/index/" target="_blank" class="custom-link">我的博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    iOS面试题总结
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../ui/ui.html">
            
                <a href="../ui/ui.html">
            
                    
                    1、UI视图相关面试题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../ui/UITableview.html">
            
                <a href="../ui/UITableview.html">
            
                    
                    1.1UITableview相关面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../ui/shujutongbu.html">
            
                <a href="../ui/shujutongbu.html">
            
                    
                    1.2数据源同步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../ui/shijianchuandi.html">
            
                <a href="../ui/shijianchuandi.html">
            
                    
                    1.3UI事件传递与响应
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../ui/tuxiangxianshi.html">
            
                <a href="../ui/tuxiangxianshi.html">
            
                    
                    1.4UI图像显示原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../ui/kadundiaozheng.html">
            
                <a href="../ui/kadundiaozheng.html">
            
                    
                    1.5UI卡顿掉帧原因
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../ui/yibuhuizhi.html">
            
                <a href="../ui/yibuhuizhi.html">
            
                    
                    1.6异步绘制原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../ui/lipingxuanran.html">
            
                <a href="../ui/lipingxuanran.html">
            
                    
                    1.7离屏渲染
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../oc/2.html">
            
                <a href="../oc/2.html">
            
                    
                    2、OC语言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../oc/2.1.html">
            
                <a href="../oc/2.1.html">
            
                    
                    2.1OC相关面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../oc/2.2.html">
            
                <a href="../oc/2.2.html">
            
                    
                    2.2分类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../oc/2_4.html">
            
                <a href="../oc/2_4.html">
            
                    
                    2.4扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../oc/2.5.html">
            
                <a href="../oc/2.5.html">
            
                    
                    2.5代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../oc/2.6.html">
            
                <a href="../oc/2.6.html">
            
                    
                    2.6通知
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../oc/2.7.html">
            
                <a href="../oc/2.7.html">
            
                    
                    2.7KVO
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../oc/2.8.html">
            
                <a href="../oc/2.8.html">
            
                    
                    2.8KVC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../oc/2.9.html">
            
                <a href="../oc/2.9.html">
            
                    
                    2.9属性关键字
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="1.4" data-path="3.html">
            
                <a href="3.html">
            
                    
                    3、Runtime
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="3.1.html">
            
                <a href="3.1.html">
            
                    
                    3.1对象、类对象、元类对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="3.2.html">
            
                <a href="3.2.html">
            
                    
                    3.2消息传递机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="3.3.html">
            
                <a href="3.3.html">
            
                    
                    3.3消息转发流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="3.4.html">
            
                <a href="3.4.html">
            
                    
                    3.4Method-Swizzling
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../neicun/4.html">
            
                <a href="../neicun/4.html">
            
                    
                    4、内存
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../neicun/4.1.html">
            
                <a href="../neicun/4.1.html">
            
                    
                    4.1引用计数表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../neicun/4.2.html">
            
                <a href="../neicun/4.2.html">
            
                    
                    4.2弱引用表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../neicun/4.3.html">
            
                <a href="../neicun/4.3.html">
            
                    
                    4.3ARC、MRC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../neicun/4.4.html">
            
                <a href="../neicun/4.4.html">
            
                    
                    4.4循环引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../neicun/4.5.html">
            
                <a href="../neicun/4.5.html">
            
                    
                    4.5内存管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../block/5.html">
            
                <a href="../block/5.html">
            
                    
                    5、Block
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../block/5.1.html">
            
                <a href="../block/5.1.html">
            
                    
                    5.1Block本质
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../block/5.2.html">
            
                <a href="../block/5.2.html">
            
                    
                    5.2截获变量特性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../block/5.3.html">
            
                <a href="../block/5.3.html">
            
                    
                    5.3内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../block/5.4.html">
            
                <a href="../block/5.4.html">
            
                    
                    5.4循环引用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../duoxiancheng/6.html">
            
                <a href="../duoxiancheng/6.html">
            
                    
                    6、多线程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../duoxiancheng/6.1.html">
            
                <a href="../duoxiancheng/6.1.html">
            
                    
                    6.1GCD、nsoperation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../duoxiancheng/6.2.html">
            
                <a href="../duoxiancheng/6.2.html">
            
                    
                    6.2资源共享
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../duoxiancheng/6.3.html">
            
                <a href="../duoxiancheng/6.3.html">
            
                    
                    6.3线程同步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../duoxiancheng/6.4.html">
            
                <a href="../duoxiancheng/6.4.html">
            
                    
                    6.4SpinLock等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../runloop/7.md">
            
                <span>
            
                    
                    7、RunLoop
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../runloop/7.1.md">
            
                <span>
            
                    
                    7.1事件循环
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../runloop/7.2.md">
            
                <span>
            
                    
                    7.2用户态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../runloop/7.3.md">
            
                <span>
            
                    
                    7.3核心态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../runloop/7.4.md">
            
                <span>
            
                    
                    7.4常驻线程
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../network/8.md">
            
                <span>
            
                    
                    8、网络
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../network/8.1.md">
            
                <span>
            
                    
                    8.1HTTPS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../network/8.2.md">
            
                <span>
            
                    
                    8.2对称加密算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../network/8.3.md">
            
                <span>
            
                    
                    8.3非对称加密
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../network/8.4.md">
            
                <span>
            
                    
                    8.4DNS解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../network/8.5.md">
            
                <span>
            
                    
                    8.5HTTP、TCP
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >3、Runtime</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#runtime"><b></b>Runtime</a></li></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h2 id="runtime"><a name="runtime" class="anchor-navigation-ex-anchor" href="#runtime"><i class="fa fa-link" aria-hidden="true"></i></a><a name="runtime" class="plugin-anchor" href="#runtime"><i class="fa fa-link" aria-hidden="true"></i></a>Runtime</h2>
<h5 id="&#x4E00;runtime&#x7B80;&#x4ECB;"><a name="&#x4E00;runtime&#x7B80;&#x4ECB;" class="anchor-navigation-ex-anchor" href="#&#x4E00;runtime&#x7B80;&#x4ECB;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E00;runtime&#x7B80;&#x4ECB;" class="plugin-anchor" href="#&#x4E00;runtime&#x7B80;&#x4ECB;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E00;.runtime&#x7B80;&#x4ECB;</h5>
<ul>
<li>runtime&#x7B80;&#x79F0;&#x8FD0;&#x884C;&#x65F6;&#xFF0C;OC&#x5C31;&#x662F;<code>&#x8FD0;&#x884C;&#x65F6;&#x673A;&#x5236;</code>&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x5019;&#x7684;&#x4E00;&#x4E9B;&#x673A;&#x5236;&#xFF0C;&#x5176;&#x4E2D;&#x6700;&#x4E3B;&#x8981;&#x7684;&#x662F;&#x6D88;&#x606F;&#x673A;&#x5236;&#x3002;</li>
<li>&#x5BF9;&#x4E8E;C&#x8BED;&#x8A00;&#xFF0C;<code>&#x51FD;&#x6570;&#x7684;&#x8C03;&#x7528;&#x5728;&#x7F16;&#x8BD1;&#x65F6;&#x4F1A;&#x51B3;&#x5B9A;&#x8C03;&#x7528;&#x54EA;&#x4E2A;&#x51FD;&#x6570;</code>&#x3002;</li>
<li>&#x5BF9;&#x4E8E;OC&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x5C5E;&#x4E8E;<code>&#x52A8;&#x6001;&#x8C03;&#x7528;&#x8FC7;&#x7A0B;</code>&#xFF0C;&#x5728;&#x7F16;&#x8BD1;&#x7684;&#x65F6;&#x5019;&#x4E0D;&#x80FD;&#x51B3;&#x5B9A;&#x771F;&#x6B63;&#x8C03;&#x7528;&#x54EA;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x53EA;&#x6709;&#x5728;&#x771F;&#x6B63;&#x8FD0;&#x884C;&#x7684;&#x65F6;&#x5019;&#x624D;&#x4F1A;&#x6839;&#x636E;&#x51FD;&#x6570;&#x7684;&#x540D;&#x79F0;&#x627E;&#x5230;&#x5BF9;&#x5E94;&#x7684;&#x51FD;&#x6570;&#x6765;&#x8C03;&#x7528;&#x3002;</li>
<li>&#x4E8B;&#x5B9E;&#x8BC1;&#x660E;&#xFF1A;
 &#x2460; &#x5728;&#x7F16;&#x8BD1;&#x9636;&#x6BB5;&#xFF1A;OC&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x4EFB;&#x4F55;&#x51FD;&#x6570;&#xFF0C;&#x5373;&#x4F7F;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x5E76;&#x672A;&#x5B9E;&#x73B0;&#xFF0C;&#x53EA;&#x8981;&#x58F0;&#x660E;&#x8FC7;&#x5C31;&#x4E0D;&#x4F1A;&#x62A5;&#x9519;&#x3002;
 &#x2461; &#x5728;&#x7F16;&#x8BD1;&#x9636;&#x6BB5;&#xFF1A;C&#x8BED;&#x8A00;&#x8C03;&#x7528;<code>&#x672A;&#x5B9E;&#x73B0;&#x7684;&#x51FD;&#x6570;</code>&#x5C31;&#x4F1A;&#x62A5;&#x9519;&#x3002;</li>
</ul>
<p><strong>runtime&#x7684;&#x4E94;&#x4E2A;&#x529F;&#x80FD;</strong></p>
<blockquote>
<p>1.&#x53D1;&#x9001;&#x6D88;&#x606F;
 2.&#x4EA4;&#x6362;&#x65B9;&#x6CD5;
 3.&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x65B9;&#x6CD5;
 4.&#x7ED9;&#x5206;&#x7C7B;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;
 5.&#x5B57;&#x5178;&#x8F6C;&#x6A21;&#x578B;</p>
</blockquote>
<ul>
<li>&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x7684;&#x672C;&#x8D28;&#xFF0C;&#x5C31;&#x662F;&#x8BA9;&#x5BF9;&#x8C61;&#x53D1;&#x9001;&#x6D88;&#x606F;&#x3002;</li>
<li>objc_msgSend,&#x53EA;&#x6709;&#x5BF9;&#x8C61;&#x624D;&#x80FD;&#x53D1;&#x9001;&#x6D88;&#x606F;&#xFF0C;&#x56E0;&#x6B64;&#x4EE5;objc&#x5F00;&#x5934;&#x3002;</li>
<li>&#x4F7F;&#x7528;<code>&#x6D88;&#x606F;&#x673A;&#x5236;</code>&#x524D;&#x63D0;&#xFF0C;&#x5FC5;&#x987B;&#x5BFC;&#x5165;<strong>#import <objc runtime.h=""></objc></strong> </li>
<li>&#x6D88;&#x606F;&#x673A;&#x5236;&#x7B80;&#x5355;&#x4F7F;&#x7528;&#x3002;</li>
<li>clang-rewrite-objc main.m&#x67E5;&#x770B;&#x6700;&#x7EC8;&#x751F;&#x6210;&#x4EE3;&#x7801;&#x3002;</li>
</ul>
<h5 id="&#x4E8C;runtime&#x6D88;&#x606F;&#x673A;&#x5236;"><a name="&#x4E8C;runtime&#x6D88;&#x606F;&#x673A;&#x5236;" class="anchor-navigation-ex-anchor" href="#&#x4E8C;runtime&#x6D88;&#x606F;&#x673A;&#x5236;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E8C;runtime&#x6D88;&#x606F;&#x673A;&#x5236;" class="plugin-anchor" href="#&#x4E8C;runtime&#x6D88;&#x606F;&#x673A;&#x5236;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E8C;.Runtime(&#x6D88;&#x606F;&#x673A;&#x5236;)</h5>
<p>&#x6D88;&#x606F;&#x673A;&#x5236;&#x662F;OC&#x4E2D;&#x662F;&#x6700;&#x4E3B;&#x8981;&#x7684;&#x673A;&#x5236;&#xFF0C;&#x4EFB;&#x4F55;&#x65B9;&#x6CD5;&#x7684;&#x8C03;&#x7528;&#x672C;&#x8D28;&#x90FD;&#x662F;<strong>&#x53D1;&#x9001;&#x6D88;&#x606F;</strong>&#xFF0C;&#x7528;runtime&#x53D1;&#x9001;&#x6D88;&#x606F;&#xFF0C;OC&#x5E95;&#x5C42;&#x901A;&#x8FC7;runtime&#x6765;&#x5B9E;&#x73B0;&#x3002;
 <strong>&#x9A8C;&#x8BC1;:</strong>
 <code>&#x662F;&#x5426;&#x771F;&#x7684;&#x662F;&#x8F6C;&#x6362;&#x4E3A;&#x6D88;&#x606F;&#x673A;&#x5236;</code>
 &#x7B2C;&#x4E00;&#x6B65;&#xFF1A;cd&#x8FDB;&#x5165;&#x5230;&#x8BE5;&#x6587;&#x4EF6;&#x5939;
 &#x7B2C;&#x4E8C;&#x6B65;&#xFF1A;&#x5728;&#x7EC8;&#x7AEF;&#x6267;&#x884C;<strong>clang -rewrite-objc &#x6587;&#x4EF6;&#x540D;</strong> &#x547D;&#x4EE4;
 &#x7B2C;&#x4E09;&#x6B65;&#xFF1A;&#x8BE5;&#x547D;&#x4EE4;&#x6210;&#x529F;&#x540E;&#x5C31;&#x4F1A;&#x751F;&#x6210;&#x4E00;&#x4E2A;.cpp&#x7684;&#x6587;&#x4EF6;&#x3002;</p>
<pre><code>allisondeMacBook-Pro:123 allison$ clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ViewController.m
clang: warning: using sysroot for &apos;iPhoneSimulator&apos; but targeting &apos;MacOSX&apos; [-Wincompatible-sysroot]
/var/folders/nm/4974_cj15s5gyjfg8wj077qm0000gn/T/ViewController-78b550.mi:12798:188: warning: 
      &apos;kCFCalendarUnitWeek&apos; is deprecated: first deprecated in macOS 10.10 - Use
      kCFCalendarUnitWeekOfYear or kCFCalendarUnitWeekOfMonth instead
      [-Wdeprecated-declarations]
  ...or NSCalendarUnitWeekOfYear, depending on which you mean&quot;))) = kCFCalend...
                                                                    ^
/var/folders/nm/4974_cj15s5gyjfg8wj077qm0000gn/T/ViewController-78b550.mi:5147:2: note: 
      &apos;kCFCalendarUnitWeek&apos; has been explicitly marked deprecated here
 kCFCalendarUnitWeek __attribute__((availability(macos,introduced=10.4,d...
 ^
1 warning generated.
</code></pre><p>&#x67E5;&#x770B;ViewController.cpp&#x6587;&#x4EF6;&#xFF0C;&#x6211;&#x4EEC;&#x53D1;&#x73B0;&#x6709;<strong>64871</strong>&#x884C;&#x4EE3;&#x7801;&#xFF0C;&#x67E5;&#x627E;<strong>viewDidLoad</strong>&#x65B9;&#x6CD5;&#xFF0C;&#x6211;&#x4EEC;&#x770B;.cpp&#x6587;&#x4EF6;&#x4E2D;viewDdiload&#x65B9;&#x6CD5;&#x4E2D;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre><code>// @implementation ViewController

static void _I_ViewController_viewDidLoad(ViewController * self, SEL _cmd) {
    ((void (*)(__rw_objc_super *, SEL))(void *)objc_msgSendSuper)((__rw_objc_super){(id)self, (id)class_getSuperclass(objc_getClass(&quot;ViewController&quot;))}, sel_registerName(&quot;viewDidLoad&quot;));


    id objc = ((NSObject *(*)(id, SEL))(void *)objc_msgSend)((id)objc_getClass(&quot;NSObject&quot;), sel_registerName(&quot;alloc&quot;));
    objc = ((id (*)(id, SEL))(void *)objc_msgSend)((id)objc, sel_registerName(&quot;init&quot;));

}
</code></pre><p>&#x6211;&#x4EEC;<strong>ViewController.m</strong>&#x5199;&#x7684;&#x4EE3;&#x7801;</p>
<pre><code>- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    id objc = [NSObject alloc];
    objc = [objc init];
}
</code></pre><p>&#x4F8B;&#x5B50;&#xFF1A;&#x8FD0;&#x7528;&#x8FD0;&#x884C;&#x65F6;&#x53BB;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;NSObject&#x5BF9;&#x8C61;&#x3002;(&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x53C2;&#x8003;ViewController.cpp&#x7C7B;&#x91CC;&#x9762;&#x7684;viewDidLoad&#x65B9;&#x6CD5;)</p>
<pre><code>    id objc = ((NSObject *(*)(id, SEL))(void *)objc_msgSend)((id)objc_getClass(&quot;NSObject&quot;), sel_registerName(&quot;alloc&quot;));
    objc = ((id (*)(id, SEL))(void *)objc_msgSend)((id)objc, sel_registerName(&quot;init&quot;));
</code></pre><p>&#x4E0A;&#x9762;&#x8FD9;&#x4E2A;&#x662F;&#x6700;&#x5E95;&#x5C42;&#x7684;&#xFF0C;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7528;&#x82F9;&#x679C;&#x5C01;&#x88C5;&#x597D;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x6548;&#x679C;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF1A;</p>
<pre><code>    id objc = objc_msgSend([NSObject class], @selector(alloc));
    objc = objc_msgSend(objc, @selector(init));
</code></pre><p>&#x8FD9;&#x91CC;&#xFF0C;&#x4ECE;&#x63A7;&#x5236;&#x53F0;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#xFF0C;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5206;&#x914D;&#x5185;&#x5B58;&#xFF0C;&#x5E76;&#x4E14;&#x6CA1;&#x6709;&#x9519;&#x8BEF;&#x3002;</p>
<p><img src="../../img/ui-3-0-1.png" alt="img"></p>
<p><strong>Tips1</strong></p>
<p>&#x672C;&#x6765;&#x60F3;&#x5728;main&#x51FD;&#x6570;&#x4E2D;&#x8BD5;&#x9A8C;&#xFF0C;&#x4F46;&#x662F;&#x5728;main&#x51FD;&#x6570;&#x4E2D;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F7F;&#x7528; <code>allison$ clang -rewrite-objc main.m</code>&#x547D;&#x4EE4;&#x7684;&#x65F6;&#x5019;&#x603B;&#x662F;&#x62A5;&#x5982;&#x4E0B;&#x9519;&#x8BEF;&#xFF0C;&#x6240;&#x4EE5;&#x6700;&#x540E;&#x5728;ViewController&#x4E2D;&#x751F;&#x6210;cpp&#x6587;&#x4EF6;&#x6210;&#x529F;&#x3002;&#xFF08;&#x6682;&#x4E0D;&#x6E05;&#x695A;&#x539F;&#x56E0;&#xFF0C;&#x8FD8;&#x8BF7;&#x5404;&#x4F4D;&#x77E5;&#x9053;&#x7684;&#x7559;&#x8A00;&#x6307;&#x6B63;&#xFF09;</p>
<pre><code>allisondeMacBook-Pro:Clang allison$ clang -rewrite-objc main.m
main.m:9:9: fatal error: &apos;UIKit/UIKit.h&apos; file not found
#import &lt;UIKit/UIKit.h&gt;
        ^~~~~~~~~~~~~~~
1 error generated.
allisondeMacBook-Pro:
</code></pre><p><strong>Tips2</strong></p>
<p>&#x6211;&#x4EEC;&#x7528;<strong>objc_msgSend</strong>&#x51FD;&#x6570;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EF;&#x80FD;&#x6CA1;&#x6709;&#x63D0;&#x793A;&#xFF0C;&#x8FD9;&#x662F;&#x56E0;&#x4E3A;&#x5728;xcode6&#x4E4B;&#x540E;&#xFF0C;&#x82F9;&#x679C;&#x4E0D;&#x63A8;&#x8350;&#x4F7F;&#x7528;runtime&#xFF0C;&#x56E0;&#x4E3A;&#x82F9;&#x679C;&#x4E0D;&#x60F3;&#x8BA9;&#x5F00;&#x53D1;&#x8005;&#x4E86;&#x89E3;&#x5E95;&#x5C42;&#x7684;&#x5B9E;&#x73B0;&#xFF0C;&#x53EA;&#x60F3;&#x8BA9;&#x5F00;&#x53D1;&#x8005;&#x76F4;&#x63A5;&#x4F7F;&#x7528;API&#x5373;&#x53EF;&#x3002;&#x4F46;&#x662F;&#x8FD9;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5C06;&#x4E25;&#x683C;&#x68C0;&#x6D4B;&#x6D88;&#x606F;&#x673A;&#x5236;&#x8FD9;&#x4E2A;&#x9009;&#x9879;&#x5173;&#x95ED;&#xFF0C;&#x4F7F;&#x7528;<strong>objc_msgSend</strong>&#x51FD;&#x6570;&#x7684;&#x65F6;&#x5019;&#x4FBF;&#x4F1A;&#x63D0;&#x793A;&#x4E86;&#xFF0C;&#x8BBE;&#x7F6E;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="../../img/ui-3-0-2.png" alt="img"></p>
<p><img src="../../img/ui-3-0-3.png" alt="img"></p>
<h5 id="&#x4E09;-runtime&#x6D88;&#x606F;&#x673A;&#x5236;&#x8C03;&#x7528;&#x591A;&#x4E2A;&#x53C2;&#x6570;"><a name="&#x4E09;-runtime&#x6D88;&#x606F;&#x673A;&#x5236;&#x8C03;&#x7528;&#x591A;&#x4E2A;&#x53C2;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x4E09;-runtime&#x6D88;&#x606F;&#x673A;&#x5236;&#x8C03;&#x7528;&#x591A;&#x4E2A;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E09;-runtime&#x6D88;&#x606F;&#x673A;&#x5236;&#x8C03;&#x7528;&#x591A;&#x4E2A;&#x53C2;&#x6570;" class="plugin-anchor" href="#&#x4E09;-runtime&#x6D88;&#x606F;&#x673A;&#x5236;&#x8C03;&#x7528;&#x591A;&#x4E2A;&#x53C2;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E09;. Runtime(&#x6D88;&#x606F;&#x673A;&#x5236;&#x8C03;&#x7528;&#x591A;&#x4E2A;&#x53C2;&#x6570;)</h5>
<p><strong>&#x5F00;&#x53D1;&#x4E2D;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x7528;runtime&#xFF1F;</strong></p>
<blockquote>
<p>1.&#x53EF;&#x4EE5;&#x5E2E;&#x6211;&#x4EEC;&#x8C03;&#x7528;&#x79C1;&#x6709;&#x7684;&#x65B9;&#x6CD5;&#x3002;&#xFF08;&#x4F8B;&#x5B50;&#xFF1A;&#x540C;&#x4E8B;&#x5C01;&#x88C5;&#x7684;&#x4E00;&#x4E2A;&#x6BD4;&#x8F83;&#x597D;&#x7684;&#x7C7B;&#xFF0C;&#x8BE5;&#x7C7B;&#x4E2D;&#x90FD;&#x662F;&#x79C1;&#x6709;&#x65B9;&#x6CD5;&#xFF0C;&#x6211;&#x4EEC;&#x60F3;&#x4F7F;&#x7528;&#x8BE5;&#x65B9;&#x6CD5;&#xFF0C;&#x4E00;&#x822C;&#x662F;&#x4E0D;&#x4F1A;&#x76F4;&#x63A5;&#x4FEE;&#x6539;.h&#x6587;&#x4EF6;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;runtime&#x6765;&#x5B9E;&#x73B0;&#xFF09;&#x3002;</p>
<p>2.&#x82F9;&#x679C;&#x7CFB;&#x7EDF;API&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x53D1;&#x73B0;&#x67D0;&#x4E2A;&#x79C1;&#x6709;&#x7684;API&#x6BD4;&#x8F83;&#x597D;&#x7528;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x4F7F;&#x7528;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;objc_msgSend&#x6765;&#x8C03;&#x7528;&#x79C1;&#x6709;&#x7684;api&#x3002;</p>
</blockquote>
<h5 id="&#x56DB;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6D41;&#x7A0B;"><a name="&#x56DB;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6D41;&#x7A0B;" class="anchor-navigation-ex-anchor" href="#&#x56DB;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6D41;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x56DB;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6D41;&#x7A0B;" class="plugin-anchor" href="#&#x56DB;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6D41;&#x7A0B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x56DB;.&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6D41;&#x7A0B;</h5>
<pre><code>&#x8C03;&#x7528;set&#x65B9;&#x6CD5;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;&#xFF1A;&#x7C7B;&#x5BF9;&#x8C61;&#x7684;&#x65B9;&#x6CD5;&#x5217;&#x8868;&#xFF1B;&#x7C7B;&#x65B9;&#x6CD5;&#xFF1A;&#x5143;&#x7C7B;&#x4E2D;&#x65B9;&#x6CD5;&#x5217;&#x8868;&#x3002;
</code></pre><ul>
<li>&#x5185;&#x5B58;&#x4E94;&#x5927;&#x533A;&#xFF1A;</li>
<li>1.&#x6808;&#xFF1A;&#x4E0D;&#x9700;&#x8981;&#x624B;&#x52A8;&#x7BA1;&#x7406;&#x5185;&#x5B58;&#xFF0C;&#x81EA;&#x52A8;&#x7BA1;&#x7406;</li>
<li>2.&#x5806;&#xFF1A;&#x9700;&#x8981;&#x624B;&#x52A8;&#x7BA1;&#x7406;&#x5185;&#x5B58;&#xFF0C;&#x624B;&#x52A8;&#x91CA;&#x653E;</li>
<li>3.&#x9759;&#x6001;&#x533A;</li>
<li>4.&#x5E38;&#x91CF;&#x533A;</li>
<li>5.&#x65B9;&#x6CD5;&#x533A;</li>
</ul>
<p><strong>&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6D41;&#x7A0B;&#xFF1A;</strong></p>
<p><img src="../../img/ui-3-0-4.png" alt="img"></p>
<blockquote>
<p>1.&#x901A;&#x8FC7;isa&#x6307;&#x9488;&#x53BB;&#x5BF9;&#x5E94;&#x7684;&#x7C7B;&#x4E2D;&#x67E5;&#x627E;&#x3002;
 2.&#x6CE8;&#x518C;&#x65B9;&#x6CD5;&#x7F16;&#x53F7;
 3.&#x6839;&#x636E;&#x65B9;&#x6CD5;&#x7F16;&#x53F7;&#x53BB;&#x67E5;&#x627E;&#x5BF9;&#x5E94;&#x7684;&#x65B9;&#x6CD5;&#x3002;
 4.&#x627E;&#x5230;&#x53EA;&#x662F;&#x6700;&#x7EC8;&#x51FD;&#x6570;&#x5B9E;&#x73B0;&#x5730;&#x5740;&#xFF0C;&#x6839;&#x636E;&#x5730;&#x5740;&#x53BB;&#x65B9;&#x6CD5;&#x533A;&#x8C03;&#x7528;&#x5BF9;&#x5E94;&#x51FD;&#x6570;&#x3002;</p>
</blockquote>
<h5 id="&#x4E94;runtime&#x4EA4;&#x6362;&#x65B9;&#x6CD5;&#x81EA;&#x5B9A;&#x4E49;uiimage"><a name="&#x4E94;runtime&#x4EA4;&#x6362;&#x65B9;&#x6CD5;&#x81EA;&#x5B9A;&#x4E49;uiimage" class="anchor-navigation-ex-anchor" href="#&#x4E94;runtime&#x4EA4;&#x6362;&#x65B9;&#x6CD5;&#x81EA;&#x5B9A;&#x4E49;uiimage"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E94;runtime&#x4EA4;&#x6362;&#x65B9;&#x6CD5;&#x81EA;&#x5B9A;&#x4E49;uiimage" class="plugin-anchor" href="#&#x4E94;runtime&#x4EA4;&#x6362;&#x65B9;&#x6CD5;&#x81EA;&#x5B9A;&#x4E49;uiimage"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E94;.Runtime(&#x4EA4;&#x6362;&#x65B9;&#x6CD5;&amp;&#x81EA;&#x5B9A;&#x4E49;UIImage)</h5>
<p><strong>&#x5F00;&#x53D1;&#x4E2D;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x4F7F;&#x7528;runtime(&#x4EA4;&#x6362;&#x65B9;&#x6CD5;)&#xFF1F;</strong>
 &#x9700;&#x6C42;1&#xFF1A;&#x6BCF;&#x6B21;UIImage&#x52A0;&#x8F7D;&#x56FE;&#x7247;&#xFF0C;&#x8FD4;&#x56DE;&#x662F;&#x5426;&#x52A0;&#x8F7D;&#x6210;&#x529F;&#xFF01;</p>
<p><strong>&#x65B9;&#x6CD5;1.&#xFF1A;</strong>&#x81EA;&#x5B9A;&#x4E49;UIImage&#x7C7B;&#x3002;
 <code>&#x5F0A;&#x7AEF;&#xFF1A;&#x2460;.&#x6BCF;&#x6B21;&#x4F7F;&#x7528;&#x90FD;&#x9700;&#x8981;&#x5BFC;&#x5165; &#x2461;.&#x8001;&#x9879;&#x76EE;/&#x5927;&#x9879;&#x76EE;&#x5927;&#x91CF;&#x4F7F;&#x7528;UIImage&#xFF0C;&#x66FF;&#x6362;&#x4E0D;&#x6613;&#x3002;</code>
 <strong>&#x65B9;&#x6CD5;2&#xFF1A;</strong> &#x7ED9;UIImage&#x6DFB;&#x52A0;&#x5206;&#x7C7B;&#x3002;
 <code>&#x5F0A;&#x7AEF;&#xFF1A;&#x2460;.&#x5728;&#x5206;&#x7C7B;&#x4E2D;&#x65B9;&#x6700;&#x597D;&#x4E0D;&#x8981;&#x91CD;&#x5199;&#x7CFB;&#x7EDF;&#x65B9;&#x6CD5;&#xFF0C;&#x4E00;&#x65E6;&#x91CD;&#x5199;&#xFF0C;&#x628A;&#x7CFB;&#x7EDF;&#x65B9;&#x6CD5;&#x5B9E;&#x73B0;&#x5C31;&#x7ED9;&#x8986;&#x76D6;&#x4E86;&#x3002;&#x2461;&#x5206;&#x7C7B;&#x4E2D;&#x4E0D;&#x80FD;&#x8C03;&#x7528;super&#x65B9;&#x6CD5;&#x3002;</code>
 <strong>&#x65B9;&#x6CD5;3&#xFF1A;</strong>&#x4F7F;&#x7528;runtime(&#x4EA4;&#x6362;&#x65B9;&#x6CD5;)&#x6765;&#x5B9E;&#x73B0;&#x3002;</p>
<p><img src="../../img/ui-3-0-5.png" alt="img"></p>
<p>(1)&#x7ED9;&#x7CFB;&#x7EDF;&#x7684;&#x65B9;&#x6CD5;&#x6DFB;&#x52A0;&#x5206;&#x7C7B;&#x3002;
 (2)&#x81EA;&#x5DF1;&#x5B9E;&#x73B0;&#x4E00;&#x4E2A;&#x5E26;&#x6709;&#x6269;&#x5C55;&#x529F;&#x80FD;&#x7684;&#x65B9;&#x6CD5;,&#x5982;&#xFF1A;<code>bdf_imageNamed</code>&#x3002;
 (3)&#x4EA4;&#x6362;<code>imageNamed</code>&#x548C;<code>bdf_imageNamed</code>&#x65B9;&#x6CD5;&#x3002;</p>
<p>&#x4E3B;&#x8981;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre><code>    // &#x83B7;&#x53D6;&#x7CFB;&#x7EDF;&#x65B9;&#x6CD5;
    // Class  _Nullable __unsafe_unretained cls &#x83B7;&#x53D6;&#x90A3;&#x4E2A;&#x7C7B;&#x7684;&#x65B9;&#x6CD5;
    // SEL  _Nonnull name&#xFF1A;&#x83B7;&#x53D6;&#x90A3;&#x4E2A;&#x65B9;&#x6CD5;
    Method imageNameMethod = class_getClassMethod(self, @selector(selectedImage:));
    // &#x83B7;&#x53D6;&#x81EA;&#x5B9A;&#x4E49;&#x65B9;&#x6CD5;
    Method bdf_imageNameMethod = class_getClassMethod(self, @selector(bdf_selectedImage:));
    // &#x4EA4;&#x6362;&#x65B9;&#x6CD5;
    method_exchangeImplementations(imageNameMethod, bdf_imageNameMethod);
</code></pre><h5 id="&#x516D;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x65B9;&#x6CD5;"><a name="&#x516D;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x516D;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x516D;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x65B9;&#x6CD5;" class="plugin-anchor" href="#&#x516D;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x516D;.Runtime(&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x65B9;&#x6CD5;)</h5>
<p>&#x8D77;&#x6E90;&#xFF1A;&#x9762;&#x8BD5;&#x9898;&#x4E2D;&#xFF0C;&#x95EE;&#x6709;&#x6CA1;&#x6709;&#x4F7F;&#x7528;&#x8FC7;<strong>performSelector</strong>?
 <code>self performSelector:&lt;#(SEL)#&gt;</code>
 &#x7B54;&#xFF1A;&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x65B9;&#x6CD5;&#x7684;&#x65F6;&#x5019;&#x4F7F;&#x7528;&#x8FC7;&#xFF01;
 &#x8FD9;&#x91CC;&#x8BF7;&#x81EA;&#x884C;&#x67E5;&#x9605;<a href="https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtDynamicResolution.html#//apple_ref/doc/uid/TP40008048-CH102-SW2" target="_blank">runtime&#x5B98;&#x65B9;&#x6587;&#x6863;</a>&#x8FDB;&#x884C;&#x4E86;&#x89E3;&#x3002;&#x76EE;&#x524D;&#x6CA1;&#x6709;get&#x5230;Runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x65B9;&#x6CD5;&#x65B9;&#x6CD5;&#x7684;&#x7528;&#x5904;~   &#x1F602;</p>
<h5 id="&#x4E03;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;"><a name="&#x4E03;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x4E03;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E03;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;" class="plugin-anchor" href="#&#x4E03;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E03;.Runtime(&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;)</h5>
<p><strong>&#x5F00;&#x53D1;&#x4E2D;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x9700;&#x8981;&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#xFF1F;</strong>
 &#x573A;&#x666F;1&#xFF1A;&#x5728;&#x5206;&#x7C7B;&#x4E2D;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#xFF0C;&#x901A;&#x8FC7;<code>objc_setAssociatedObject</code>&#x65B9;&#x6CD5;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#x3002;
 &#x573A;&#x666F;2&#xFF1A;&#x7ED9;&#x7CFB;&#x7EDF;&#x7684;&#x7C7B;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;runtime&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#x65B9;&#x6CD5;&#x3002;
 &#x5982;&#xFF1A;</p>
<pre><code>- (void)setName:(NSString *)name {
    // id  _Nonnull object &#x7ED9;&#x90A3;&#x4E2A;&#x5BF9;&#x8C61;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;
    // const void * _Nonnull key &#x5C5E;&#x6027;&#x540D;&#x79F0;
    // id  _Nullable value &#x5C5E;&#x6027;&#x503C;
    // objc_AssociationPolicy policy &#x4FDD;&#x5B58;&#x7B56;&#x7565;
    objc_setAssociatedObject(self, @&quot;name&quot;, name, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (NSString *)name {
    return objc_getAssociatedObject(self, @&quot;name&quot;);
}
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../oc/2.9.html" class="navigation navigation-prev " aria-label="Previous page: 2.9属性关键字">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="3.1.html" class="navigation navigation-next " aria-label="Next page: 3.1对象、类对象、元类对象">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3、Runtime","level":"1.4","depth":1,"next":{"title":"3.1对象、类对象、元类对象","level":"1.4.1","depth":2,"path":"md/runtime/3.1.md","ref":"md/runtime/3.1.md","articles":[]},"previous":{"title":"2.9属性关键字","level":"1.3.8","depth":2,"path":"md/oc/2.9.md","ref":"md/oc/2.9.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","github","github-buttons","donate","sharing-plus","anchor-navigation-ex","favicon","livereload"],"styles":{"website":"./styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"github":{"url":"https://github.com/zhou415770319"},"livereload":{},"splitter":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"../../img/alipay.JPG","alipayText":" ","button":"赞赏","title":"","wechat":"","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{"shortcut":"./source/images/favicon.jpg","bookmark":"./source/images/favicon.jpg","appleTouch":"./source/images/apple-touch-icon.jpg","appleTouchMore":{"120x120":"./source/images/apple-touch-icon.jpg","180x180":"./source/images/apple-touch-icon.jpg"}},"github-buttons":{"buttons":[{"user":"zhou415770319","repo":"iosKnowledges","type":"star","size":"small","count":true}]},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"theme":"default","author":"zhoufei","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"zhoufei-iosknowledges","language":"zh-hans","links":{"sidebar":{"我的博客":"http://www.feiyum.cn/index/"}},"gitbook":"3.2.3","description":"ios面试知识点总结"},"file":{"path":"md/runtime/3.md","mtime":"2019-05-03T14:40:51.321Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-03T14:51:39.741Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

